<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>cookie</title>
</head>
<body>
    <input id="setBtn" type="button" value="设置cookie">
    <input id="getBtn" type="button" value="获取cookie">
    <script>
        document.getElementById("setBtn").onclick = function(){
            document.cookie = "a=1;expires=Thu, 18 Dec 2043 12:00:00 GMT";
        };
        document.getElementById("getBtn").onclick = function(){
            console.log("document.cookie：",document.cookie);
        }

    </script>    
</body>
</html>